package com.clementheliou.cheliou.dal.dao.member;

import com.clementheliou.cheliou.dal.dao.generic.GenericDAO;
import com.clementheliou.cheliou.dal.dao.member.exception.EMailAlreadyUsedConstraintViolationException;
import com.clementheliou.cheliou.dal.model.member.Member;

/**
 * Interface of the DAO dedicated to the {@link Member} entities.
 * 
 * @author Clément HELIOU (clement.heliou@gmail.com)
 * @see {@link GenericDAO};
 * @see {@link Member}.
 * @since 1.0
 */
public interface MemberDAO extends GenericDAO<Member> {

	/**
	 * Gets a member from its email which is used as login.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @param email the email of the member we are looking for.
	 * @return the member if exists, <code>null</code> otherwise.
	 * @since 1.0
	 */
	Member getMemberFromEMail(String email);

	/**
	 * Persists the given member, previously checking the DB unicity constraint
	 * on the login field. This is the only moment where this check can be
	 * relevant.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @param memberToSave the transient member to be saved.
	 * @throws EMailAlreadyUsedConstraintViolationException if the login exists.
	 * @since 1.0
	 */
	void saveMember(Member memberToSave) throws EMailAlreadyUsedConstraintViolationException;
}
